package velhaxo.testes;
public class bus {
        public static void main(String[] args) throws InterruptedException {
                passenger p = new passenger();
                p.start();
                synchronized (p) {
                        System.out.println("passenger is waiting for the bus ");
                        p.wait();
                        System.out.println("passenger  got notification");
                }
                System.out.println("after "+p.total+" time");
        }
}

class passenger  extends Thread {
        int total = 0;

        public void run() {
                synchronized (this) { 
                        System.out.println("wait .... ");
                        for (int i = 0; i <= 1000; i++)
                                total = total + i;
                        System.out.println("passenger  is given  notification call");
                        notify();
                }
        }
} 